package aad.storyboard.view;

import android.app.Activity;
import android.os.Handler;
import android.view.View;
import android.webkit.WebView;
import android.widget.ViewFlipper;

public class JavaScriptInterface {
	
	 
	 static Activity activity;	 
	 View wikiView;	 
	 static ViewFlipper flipper; 
	 private static Handler mHandler=new Handler();

	    /** Instantiate the interface and set the context */
	    public JavaScriptInterface(Activity a, WebView view, ViewFlipper flip)
	    {
	       activity=a;
	       wikiView=view;	
	       JavaScriptInterface.flipper=flip;
	        
	    }

	    public void showExplanation(String word)
	    {   
	    	String file="file:///android_asset/"+word+".html";
	    	((WebView)wikiView).loadUrl(file);        
	        
	        mHandler.removeCallbacks(mTransitionTask);	    	
		    mHandler.postDelayed(mTransitionTask, 100);		    
	        	    	
	    
	    }
	    
	    private static Runnable mTransitionTask = new Runnable() {
			   @Override
			public void run() {	
				   System.out.println("Java script triggered");
				   //SlideTransition t=new SlideTransition(300, flipper, activity);
				   //flipper.setDisplayedChild(2);
				   //flipper.invalidate();
			   }
			};
		



}
